package aptech.eproject.logictics.db;

import java.io.Serializable;
import javax.persistence.*;
import java.util.Set;

/**
 * The persistent class for the CITY database table.
 * 
 */
@Entity
@Table(name = "CITY")
public class City implements Serializable {

    private static final long serialVersionUID = 1L;
    private int cityId;
    private String cityName;
    private boolean isDeleted;
    private Set<Branch> branches;
    private Set<Customer> customers;

    public City() {
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "CITY_ID")
    public int getCityId() {
        return this.cityId;
    }

    public void setCityId(int cityId) {
        this.cityId = cityId;
    }

    @Column(name = "CITY_NAME", nullable = false)
    public String getCityName() {
        return this.cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    @Column(name = "IS_DELETED", nullable = true)
    public boolean getIsDeleted() {
        return this.isDeleted;
    }

    public void setIsDeleted(boolean isDeleted) {
        this.isDeleted = isDeleted;
    }

    //bi-directional many-to-one association to Branch
    @OneToMany(mappedBy = "city", fetch = FetchType.EAGER)
    public Set<Branch> getBranches() {
        return this.branches;
    }

    public void setBranches(Set<Branch> branches) {
        this.branches = branches;
    }

    public Branch addBranch(Branch branch) {
        getBranches().add(branch);
        return branch;
    }

    public Branch removeBranch(Branch branch) {
        getBranches().remove(branch);
        branch.setCity(null);
        return branch;
    }

    //bi-directional many-to-one association to Customer
    @OneToMany(mappedBy = "city", fetch = FetchType.EAGER)
    public Set<Customer> getCustomers() {
        return this.customers;
    }

    public void setCustomers(Set<Customer> customers) {
        this.customers = customers;
    }

    public Customer addCustomer(Customer cust) {
        getCustomers().add(cust);
        return cust;
    }

    public Customer removeCustomer(Customer cust) {
        getCustomers().remove(cust);
        cust.setCity(null);
        return cust;
    }
}
